package mya.mes.mdc.websocket;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import mya.common.model.json.JsonHelper;

class JsonMsg {

    static String asString(String msg, boolean success, ArrayNode nodes) {
        ObjectNode json = JsonHelper.createNode();

        json.put("msg", msg);

        json.put("success", success);

        if (nodes != null) {


            ArrayNode data = json.putArray("data");

            data.addAll(nodes);

        }

        String jsonStr = json.toString();
        return jsonStr;
    }

}
